<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: zhangyi
// +----------------------------------------------------------------------

// 应用公共文件
error_reporting(E_ERROR);
session_start();
date_default_timezone_set('PRC');

function zhangyi()
{
	print_r(1111);
}

/**
 * 获取树形目录
 * @param  [arr] $data      [description]
 * @param  [int] $pId       [description]
 * @param  [int] $field_pid [description]
 * @param  [int] $field_id  [description]
 * @return [arr]            [description]
 */
function getTree($data, $pId,$field_pid,$field_id) {
    $tree = '';
    foreach($data as $k =>$v) {
        if($v[$field_pid] == $pId)    {
            $v['subMenu'] = getTree($data, $v[$field_id],$field_pid,$field_id);
            if ( empty($v["subMenu"])  ) {
                unset($v['subMenu']) ;
            }
            $tree[] = $v;
        }
    }
    return $tree;
}

function array_sort($arr,$keys,$type='asc',$old_key="yes"){
    $keysvalue = $new_array = array();
    foreach ($arr as $k=>$v){
        $keysvalue[$k] = $v[$keys];
    }
    if($type == 'asc'){
        asort($keysvalue);
    }else{
        arsort($keysvalue);
    }
    reset($keysvalue);
    foreach ($keysvalue as $k=>$v){
        if($old_key == "yes"){
            $new_array[$k] = $arr[$k];
        }else{
            $new_array[] = $arr[$k];
        }
    }
    return $new_array;
}


function secendHMS($intSec){
   return sprintf("%02d",intval($intSec/3600)).":".sprintf("%02d",intval(($intSec%3600)/60)).":".sprintf("%02d",intval((($intSec%3600)%60)));
}

